﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;

namespace Yyd.DependencyInjection
{
    public class SwashbuckleConventionalRegistrar : ConventionalRegistrarBase
    {
        public static List<string> FilePaths { get; set; } = new List<string>();

        public static string BasePath = AppContext.BaseDirectory;

        public override void AddAssembly(IServiceCollection services, Assembly assembly)
        {
            var xmlFile = $"{assembly.GetName().Name}.xml";

            // TODO 目前仅支持
            if (!xmlFile.StartsWith("Yyd"))
            {
                return;
            }

            var filePath = Path.Combine(BasePath, xmlFile);
            if (File.Exists(filePath))
            {
                FilePaths.AddIfNotContains(filePath);
            }
        }

        public override void AddType(IServiceCollection services, Type type)
        {
            throw new NotImplementedException();
        }
    }
}
